package com.qfjy.homework.lipengfeng;

/**
 * 实现播放器的类
 */
public class MediaAdapter implements MediaPlayer{

    //引入高级播放器
    AdvancedMediaPlayer advancedMediaPlayer;

    /**
     *
     * @param audioType  媒体类型
     */
    public MediaAdapter(String audioType) {
        if(audioType.equalsIgnoreCase("vlc") ){
            advancedMediaPlayer = new VlcPlayer();
        } else if (audioType.equalsIgnoreCase("mp4")){
            advancedMediaPlayer = new Mp4Player();
        }
    }

    /**
     * 播放的方法实现
     * @param audioType
     * @param fileName
     */

    @Override
    public void play(String audioType, String fileName) {
        if(audioType.equalsIgnoreCase("vlc")){
            advancedMediaPlayer.playVlc(fileName);
        }else if(audioType.equalsIgnoreCase("mp4")){
            advancedMediaPlayer.playMp4(fileName);
        }
    }
}
